package com.acmetelecom.call;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.acmetelecom.customer.Customer;

public class CallEventBuilder {
	public static class CallBuilder {

		private CallStart start;

		public CallBuilder(CallStart start) {
			this.start = start;
		}

		public Call then(CallEnd end) {
			return new Call(start, end);
		}
	}

	public static class ToBuilder {

		private Customer from;
		private Customer to;

		public ToBuilder(Customer from, Customer to) {
			this.from = from;
			this.to = to;
		}

		public CallStart thatStartedAt(DateTime time1) {
			return new CallStart(from, to ,time1);
		}

		public CallEnd endedAt(DateTime time2) {
			return new CallEnd(from, to , time2);
		}
	}

	public static class FromBuilder {

		private Customer from;

		public FromBuilder(Customer from) {
			this.from = from;
		}
		
		public ToBuilder to(Customer to) {
			return new ToBuilder(from, to);
		}

	}

	public static FromBuilder aCallFrom(Customer from) {
		return new FromBuilder(from);
	}
	
	public static DateTime asDateTime( String s ) {
		DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MM/yy hh:mmaa");
		return DateTime.parse(s, fmt);
	}
	
	public static CallBuilder first(CallStart start) {
		return new CallBuilder(start);
	}
}
